var REGION_PROVINCE = [];
var addressBean = {
  REGION_PROVINCE: null,
  REGION_COUNTRY: null,
  REGION_CITY: null,
  ADDRESS: null
};
function getPCA(res,callback){
  var regex = /^(北京市|天津市|重庆市|上海市|香港特别行政区|澳门特别行政区)/;
  if (!(REGION_PROVINCE = regex.exec(res.address))) {
    regex = /^(.*?(省|自治区))(.*?)$/;
    REGION_PROVINCE = regex.exec(res.address);
    addressBean.REGION_PROVINCE = REGION_PROVINCE[1];
    regexAddressBean(REGION_PROVINCE[3], addressBean,res);
  } else {
    addressBean.REGION_PROVINCE = REGION_PROVINCE[1];
    regexAddressBean(res.address, addressBean,res);
  }
  callback(addressBean);
}
function regexAddressBean(address, addressBean,res) {
  var regex = /^(.*?[市州]|.*?地区|.*?特别行政区)(.*?[市区县])(.*?)$/g;
  var addxress = regex.exec(address);
  addressBean.REGION_CITY = addxress[1];
  addressBean.REGION_COUNTRY = addxress[2];
  addressBean.ADDRESS = addxress[3] + "(" + res.name + ")";
}
module.exports = {
  getPCA: getPCA
}  